package com.im.utils;

import com.im.entity.ImUser;
import com.im.entity.vo.UserInfoVO;

/**
 * 用户上下文（基于 ThreadLocal）
 */
public class UserContext {
    private static final ThreadLocal<UserInfoVO> USER_THREAD_LOCAL = new ThreadLocal<>();

    public static void setUser(UserInfoVO user) {
        USER_THREAD_LOCAL.set(user);
    }

    public static UserInfoVO getUser() {
        return USER_THREAD_LOCAL.get();
    }

    public static void remove() {
        USER_THREAD_LOCAL.remove();
    }
}
